#include <iostream>
#include <vector>
#include <cstdio> 
#include <algorithm>

#define in read()
#define fi first
#define se second
#define pb push_back

using namespace std;

typedef long long ll;
typedef double db;
typedef vector < int >  vec;
typedef pair < int , int > pii;

int read() {
  int x = 0; bool f = 0; char ch = getchar(); while(!isdigit(ch)) f |= ch == '-',ch = getchar();
  while(isdigit(ch)) x = x * 10 + (ch ^ 48),ch = getchar(); return f ? -x : x;
}

const int N = 1e6 + 10;
const int B = 1000;

int n;

struct pot {
    int id,l,r;
    const bool operator < (const pot b) const { return l ^ b.l ? l < b.l : l & 1 ? r < b.r : r > b.r; }
}p[N];

int main() {
#ifndef ONLINE_JUDGE
    freopen("1.in","r",stdin);
#endif
    n = in; for(int i = 1;i <= n;i++) p[i].id = i,p[i].l = (in - 1) / B + 1,p[i].r = in;
    sort(p + 1,p + n + 1); for(int i = 1;i <= n;i++) printf("%d ",p[i].id); return 0;
} 
